<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.1.1">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/avatar.jpg">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/avatar.jpg">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/avatar.jpg">
  <link rel="mask-icon" href="/images/avatar.jpg" color="#222">
  <meta name="msvalidate.01" content="4AF2328B2035748153A041B7EEF3D15C">

<link rel="stylesheet" href="/css/main.css">

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Serif+SC:300,300italic,400,400italic,700,700italic%7CLobster:300,300italic,400,400italic,700,700italic%7CPingFang+SC:300,300italic,400,400italic,700,700italic%7CRoboto+Mono:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.33/fancybox/fancybox.css" integrity="sha256-gkQVf8UKZgQ0HyuxL/VnacadJ+D2Kox2TCEBuNQg5+w=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"ethanliu6.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":true,"sidebar":{"position":"left","display":"always","padding":12,"offset":18},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":true,"color":"#222","save":"manual"},"mediumzoom":true,"lazyload":true,"pangu":false,"comments":{"style":"buttons","active":"changyan","storage":true,"lazyload":false,"nav":null,"activeClass":"changyan"},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":6,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="JavaSE进阶——Day02 该篇主要讲解Java中的代码块、接口、枚举">
<meta property="og:type" content="article">
<meta property="og:title" content="JavaSE进阶——Day02 代码块、接口、枚举">
<meta property="og:url" content="http://ethanliu6.github.io/2024/04/01/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day02/day02_JavaSE%E8%BF%9B%E9%98%B6-%E4%BB%A3%E7%A0%81%E5%9D%97,%E6%8E%A5%E5%8F%A3,%E6%9E%9A%E4%B8%BE/index.html">
<meta property="og:site_name" content="&lt;font color&#x3D;&#39;white&#39; &gt;Ethan の Blog&lt;&#x2F;font&gt;">
<meta property="og:description" content="JavaSE进阶——Day02 该篇主要讲解Java中的代码块、接口、枚举">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2024-03-31T16:00:00.000Z">
<meta property="article:modified_time" content="2024-04-26T08:12:35.265Z">
<meta property="article:author" content="Ethan Liu">
<meta property="article:tag" content="Java">
<meta property="article:tag" content="Java进阶">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="http://ethanliu6.github.io/2024/04/01/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day02/day02_JavaSE%E8%BF%9B%E9%98%B6-%E4%BB%A3%E7%A0%81%E5%9D%97,%E6%8E%A5%E5%8F%A3,%E6%9E%9A%E4%B8%BE/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"http://ethanliu6.github.io/2024/04/01/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day02/day02_JavaSE%E8%BF%9B%E9%98%B6-%E4%BB%A3%E7%A0%81%E5%9D%97,%E6%8E%A5%E5%8F%A3,%E6%9E%9A%E4%B8%BE/","path":"2024/04/01/JavaNotes/JavaSE进阶/day02/day02_JavaSE进阶-代码块,接口,枚举/","title":"JavaSE进阶——Day02 代码块、接口、枚举"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>JavaSE进阶——Day02 代码块、接口、枚举 | <font color='white' >Ethan の Blog</font></title>
  








  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<style>.darkmode--activated{--body-bg-color:#282828;--content-bg-color:#333;--card-bg-color:#555;--text-color:#ccc;--blockquote-color:#bbb;--link-color:#ccc;--link-hover-color:#eee;--brand-color:#ddd;--brand-hover-color:#ddd;--table-row-odd-bg-color:#282828;--table-row-hover-bg-color:#363636;--menu-item-bg-color:#555;--btn-default-bg:#222;--btn-default-color:#ccc;--btn-default-border-color:#555;--btn-default-hover-bg:#666;--btn-default-hover-color:#ccc;--btn-default-hover-border-color:#666;--highlight-background:#282b2e;--highlight-foreground:#a9b7c6;--highlight-gutter-background:#34393d;--highlight-gutter-foreground:#9ca9b6}.darkmode--activated img{opacity:.75}.darkmode--activated img:hover{opacity:.9}.darkmode--activated code{color:#69dbdc;background:0 0}button.darkmode-toggle{z-index:9999}.darkmode-ignore,img{display:flex!important}.beian img{display:inline-block!important}</style></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title"><font color='white' >Ethan の Blog</font></p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description"><font color='#FDABC1' size=3>清醒的停留，胜过——盲目的前行</font></p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-关于我"><a href="/aboutme/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">18</span></a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类<span class="badge">14</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">53</span></a></li><li class="menu-item menu-item-love"><a href="/categories/Love/" rel="section"><i class="fas fa-heart fa-fw"></i>Love</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#static"><span class="nav-number">1.</span> <span class="nav-text">static</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BB%80%E4%B9%88%E6%98%AFstatic"><span class="nav-number">1.1.</span> <span class="nav-text">什么是static</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#static%E8%A7%A3%E5%86%B3%E7%A8%8B%E5%BA%8F%E4%B8%AD%E7%9A%84%E4%BB%80%E4%B9%88%E9%97%AE%E9%A2%98"><span class="nav-number">1.2.</span> <span class="nav-text">static解决程序中的什么问题？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#static%E6%80%8E%E4%B9%88%E4%BD%BF%E7%94%A8"><span class="nav-number">1.3.</span> <span class="nav-text">static怎么使用？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#static%E5%9C%A8%E4%BD%BF%E7%94%A8%E4%B8%AD%E7%9A%84%E6%B3%A8%E6%84%8F%E7%BB%86%E8%8A%82"><span class="nav-number">1.4.</span> <span class="nav-text">static在使用中的注意细节</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#jvm%E5%86%85%E5%AD%98%E5%88%92%E5%88%86"><span class="nav-number">1.5.</span> <span class="nav-text">JVM内存划分:</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#final"><span class="nav-number">2.</span> <span class="nav-text">final</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#final%E6%98%AF%E4%BB%80%E4%B9%88"><span class="nav-number">2.1.</span> <span class="nav-text">final是什么</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#final%E8%A7%A3%E5%86%B3%E7%A8%8B%E5%BA%8F%E4%B8%AD%E4%BB%80%E4%B9%88%E9%97%AE%E9%A2%98"><span class="nav-number">2.2.</span> <span class="nav-text">final解决程序中什么问题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#final%E6%80%8E%E4%B9%88%E4%BD%BF%E7%94%A8"><span class="nav-number">2.3.</span> <span class="nav-text">final怎么使用</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#final%E5%9C%A8%E4%BD%BF%E7%94%A8%E4%B8%AD%E7%9A%84%E6%B3%A8%E6%84%8F%E7%BB%86%E8%8A%82"><span class="nav-number">2.4.</span> <span class="nav-text">final在使用中的注意细节</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%9D%83%E9%99%90%E4%BF%AE%E9%A5%B0%E7%AC%A6"><span class="nav-number">3.</span> <span class="nav-text">权限修饰符</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%9D%83%E9%99%90%E4%BF%AE%E9%A5%B0%E7%AC%A6%E6%98%AF%E4%BB%80%E4%B9%88"><span class="nav-number">3.1.</span> <span class="nav-text">权限修饰符是什么</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%9D%83%E9%99%90%E4%BF%AE%E9%A5%B0%E7%AC%A6%E5%8F%B7%E8%A7%A3%E5%86%B3%E4%BB%80%E4%B9%88%E9%97%AE%E9%A2%98"><span class="nav-number">3.2.</span> <span class="nav-text">权限修饰符号解决什么问题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%9D%83%E9%99%90%E4%BF%AE%E9%A5%B0%E7%AC%A6%E6%80%8E%E4%B9%88%E4%BD%BF%E7%94%A8"><span class="nav-number">3.3.</span> <span class="nav-text">权限修饰符怎么使用</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%9D%83%E9%99%90%E4%BF%AE%E9%A5%B0%E7%AC%A6%E5%9C%A8%E4%BD%BF%E7%94%A8%E4%B8%AD%E7%9A%84%E6%B3%A8%E6%84%8F%E7%BB%86%E8%8A%82"><span class="nav-number">3.4.</span> <span class="nav-text">权限修饰符在使用中的注意细节</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%B7%A5%E5%85%B7%E7%B1%BB"><span class="nav-number">4.</span> <span class="nav-text">工具类</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%9C%A8%E5%BC%80%E5%8F%91%E4%B8%AD%E7%BB%8F%E5%B8%B8%E4%BC%9A%E4%BD%BF%E7%94%A8%E6%88%96%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7%E7%B1%BB"><span class="nav-number">4.1.</span> <span class="nav-text">在开发中经常会使用或开发：工具类</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%97%AE%E9%A2%98%E5%9C%A8%E4%B8%80%E4%B8%AA%E7%B1%BB%E4%B8%AD%E5%8F%AF%E4%BB%A5%E4%B9%A6%E5%86%99%E5%93%AA%E4%BA%9B%E5%86%85%E5%AE%B9"><span class="nav-number">4.2.</span> <span class="nav-text">问题：在一个类中可以书写哪些内容？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BB%A3%E7%A0%81%E5%9D%97"><span class="nav-number">4.3.</span> <span class="nav-text">代码块：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BB%A3%E7%A0%81%E5%9D%97%E5%88%92%E5%88%86"><span class="nav-number">4.4.</span> <span class="nav-text">代码块划分：</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%8E%A5%E5%8F%A3"><span class="nav-number">5.</span> <span class="nav-text">接口</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8E%A5%E5%8F%A3%E7%9A%84%E4%BD%9C%E7%94%A8%E5%88%B6%E5%AE%9A%E8%A7%84%E5%88%99"><span class="nav-number">5.1.</span> <span class="nav-text">接口的作用：制定规则</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%88%B6%E5%AE%9A%E8%A7%84%E5%88%99%E7%9A%84%E4%B8%A4%E7%A7%8D%E6%96%B9%E6%A1%88"><span class="nav-number">5.2.</span> <span class="nav-text">制定规则的两种方案：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8E%A5%E5%8F%A3%E7%9A%84%E5%AE%9A%E4%B9%89"><span class="nav-number">5.3.</span> <span class="nav-text">接口的定义：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8E%A5%E5%8F%A3%E7%9A%84%E7%89%B9%E7%82%B9"><span class="nav-number">5.4.</span> <span class="nav-text">接口的特点：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8E%A5%E5%8F%A3%E5%92%8C%E6%8A%BD%E8%B1%A1%E7%B1%BB%E7%9A%84%E7%9B%B8%E5%90%8C%E4%B9%8B%E5%A4%84"><span class="nav-number">5.5.</span> <span class="nav-text">接口和抽象类的相同之处：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8A%BD%E8%B1%A1%E7%B1%BB%E5%92%8C%E6%8E%A5%E5%8F%A3%E7%9A%84%E5%8C%BA%E5%88%AB"><span class="nav-number">5.6.</span> <span class="nav-text">抽象类和接口的区别：</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%80%BB%E7%BB%93"><span class="nav-number">6.</span> <span class="nav-text">总结：</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#static%E5%85%B3%E9%94%AE%E5%AD%97"><span class="nav-number">6.1.</span> <span class="nav-text">static关键字</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#final%E5%85%B3%E9%94%AE%E5%AD%97"><span class="nav-number">6.2.</span> <span class="nav-text">final关键字</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%9D%83%E9%99%90%E4%BF%AE%E9%A5%B0%E7%AC%A6%E5%8F%B7"><span class="nav-number">6.3.</span> <span class="nav-text">权限修饰符号</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8E%A5%E5%8F%A3-1"><span class="nav-number">6.4.</span> <span class="nav-text">接口</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BB%A3%E7%A0%81%E5%9D%97-1"><span class="nav-number">6.5.</span> <span class="nav-text">代码块</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E9%80%89%E6%8B%A9%E8%AF%AD%E5%8F%A5"><span class="nav-number">7.</span> <span class="nav-text">选择语句：</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%9E%9A%E4%B8%BE"><span class="nav-number">8.</span> <span class="nav-text">枚举</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Ethan Liu"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">Ethan Liu</p>
  <div class="site-description" itemprop="description"><font color='#0000FF' size=1.5px>语言学 | NLP | Py | Java</font></div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">53</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">18</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL2V0aGFubGl1Ng==" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;ethanliu6"><i class="fab fa-github fa-fw"></i>GitHub</span>
      </span>
      <span class="links-of-author-item">
        <span class="exturl" data-url="bWFpbHRvOmxpdWUyMzM2QGdtYWlsLmNvbQ==" title="E-Mail → mailto:liue2336@gmail.com"><i class="fa fa-envelope fa-fw"></i>E-Mail</span>
      </span>
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cHM6Ly9zcGFjZS5iaWxpYmlsaS5jb20vMTMyNzA5OTk3Nw==" title="BiliBili → https:&#x2F;&#x2F;space.bilibili.com&#x2F;1327099977"><i class="fa-brands fa-bilibili fa-fw"></i>BiliBili</span>
      </span>
      <span class="links-of-author-item">
        <a href="/categories/Love/" title="Love → &#x2F;categories&#x2F;Love&#x2F;" rel="noopener me"><i class="fa fa-heart fa-fw"></i>Love</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://ethanliu6.github.io/2024/04/01/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day02/day02_JavaSE%E8%BF%9B%E9%98%B6-%E4%BB%A3%E7%A0%81%E5%9D%97,%E6%8E%A5%E5%8F%A3,%E6%9E%9A%E4%B8%BE/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="Ethan Liu">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="<font color='white' >Ethan の Blog</font>">
      <meta itemprop="description" content="<font color='#0000FF' size=1.5px>语言学 | NLP | Py | Java</font>">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="JavaSE进阶——Day02 代码块、接口、枚举 | <font color='white' >Ethan の Blog</font>">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          JavaSE进阶——Day02 代码块、接口、枚举<span class="exturl post-edit-link" data-url="aHR0cHM6Ly9naXRodWIuY29tL0V0aGFuTGl1Ni9ldGhhbmxpdTYuZ2l0aHViLmlvL3RyZWUvbWFzdGVyL19wb3N0cy9KYXZhTm90ZXMvSmF2YVNF6L+b6Zi2L2RheTAyL2RheTAyX0phdmFTRei/m+mYti3ku6PnoIHlnZcs5o6l5Y+jLOaemuS4vi5tZA==" title="编辑"><i class="fa fa-pen-nib"></i></span>
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2024-04-01 00:00:00" itemprop="dateCreated datePublished" datetime="2024-04-01T00:00:00+08:00">2024-04-01</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">更新于</span>
      <time title="修改时间：2024-04-26 16:12:35" itemprop="dateModified" datetime="2024-04-26T16:12:35+08:00">2024-04-26</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Java%E5%85%A8%E6%A0%88/" itemprop="url" rel="index"><span itemprop="name">Java全栈</span></a>
        </span>
    </span>

  
    <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv">
      <span class="post-meta-item-icon">
        <i class="far fa-eye"></i>
      </span>
      <span class="post-meta-item-text">阅读次数：</span>
      <span id="busuanzi_value_page_pv"></span>
    </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Changyan：</span>
    
    <a title="JavaSE进阶——Day02 代码块、接口、枚举" href="/2024/04/01/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day02/day02_JavaSE%E8%BF%9B%E9%98%B6-%E4%BB%A3%E7%A0%81%E5%9D%97,%E6%8E%A5%E5%8F%A3,%E6%9E%9A%E4%B8%BE/#SOHUCS" itemprop="discussionUrl">
      <span id="sourceId::9a71e76ad768294a3365a5c88a5c26ab" class="cy_cmt_count" itemprop="commentCount"></span>
    </a>
  </span>
  
  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>972</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>4 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><blockquote class="blockquote-center">
<p>JavaSE进阶——Day02
该篇主要讲解Java中的<strong>代码块</strong>、<strong>接口</strong>、<strong>枚举</strong></p>

</blockquote>
<span id="more"></span>
<p>学习目标</p>
<ul>
<li><p>关键字</p>
<ul>
<li><p>final</p></li>
<li><p>static</p></li>
</ul></li>
<li><p>代码块</p>
<ul>
<li><p>静态代码块</p></li>
<li><p>构造代码块</p></li>
<li><p>局部代码快</p></li>
</ul></li>
<li><p>接口</p>
<ul>
<li><p>接口的作用及格式</p></li>
<li><p>接口的成员定义</p></li>
<li><p>接口在JDK不同版本中方法的改进</p></li>
</ul></li>
<li><p>枚举</p>
<ul>
<li><p>枚举的作用及格式</p></li>
<li><p>枚举的使用</p></li>
<li><p>枚举的本质</p></li>
</ul></li>
</ul>
<h2 id="static">static</h2>
<h3 id="什么是static">什么是static</h3>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">static是java语言中的修饰符关键字</span><br><span class="line">用来修饰：成员变量、成员方法</span><br></pre></td></tr></table></figure>
<h3 id="static解决程序中的什么问题">static解决程序中的什么问题？</h3>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">当程序中的某个数据需要共享时使用static修饰</span><br></pre></td></tr></table></figure>
<h3 id="static怎么使用">static怎么使用？</h3>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Student</span>&#123;</span><br><span class="line">    <span class="comment">//成员变量</span></span><br><span class="line">    <span class="keyword">private</span> String name;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> String city;<span class="comment">//静态成员变量</span></span><br><span class="line">    </span><br><span class="line">    <span class="comment">//静态成员方法</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">method</span><span class="params">()</span>&#123;</span><br><span class="line">        </span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//通过类名访问静态内容（静态的私有成员变量不能访问）</span></span><br></pre></td></tr></table></figure>
<h3 id="static在使用中的注意细节">static在使用中的注意细节</h3>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">1、静态内容是随着类的加载就存在了（早于对象创建）</span><br><span class="line">2、静态内容通常是使用： 类名.成员变量     类名.成员方法()</span><br><span class="line">3、静态方法中只能访问静态成员（静态变量、静态方法）</span><br><span class="line">4、静态方法中不能使用this关键字</span><br><span class="line">5、非静态方法中可以直接访问：静态成员</span><br></pre></td></tr></table></figure>
<h3 id="jvm内存划分">JVM内存划分:</h3>
<ol type="1">
<li>栈</li>
<li>堆</li>
<li>方法区
<ul>
<li>是由N多个不同功能的小区域组成的
<ul>
<li>静态区域：存放静态内容</li>
<li>非静态区域：存放非静态内容</li>
<li>字符串常量池：存放字符串常量</li>
</ul></li>
</ul></li>
<li>寄存器</li>
<li>本地方法区</li>
</ol>
<h2 id="final">final</h2>
<h3 id="final是什么">final是什么</h3>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">final</span>是java语言中的修饰符关键字</span><br><span class="line">用来修饰：类、变量、方法    </span><br><span class="line">    </span><br><span class="line"><span class="keyword">final</span>关键字的含义：最终的、不可改变的    </span><br></pre></td></tr></table></figure>
<h3 id="final解决程序中什么问题">final解决程序中什么问题</h3>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">1、当某个变量不允许修改数据值时，可以使用final修饰变量</span><br><span class="line">2、当某个方法不允许被子类重写时，可以使用final修饰方法</span><br><span class="line">3、当某个类不允许被继承时，可以使用final修饰类。  举例：String类</span><br></pre></td></tr></table></figure>
<h3 id="final怎么使用">final怎么使用</h3>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">final</span> class 类名&#123;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">final</span> <span class="type">int</span> COUNT=<span class="number">100</span>;</span><br><span class="line">   </span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">void</span> <span class="title function_">method</span><span class="params">()</span>&#123;</span><br><span class="line">       </span><br><span class="line">   &#125; </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="final在使用中的注意细节">final在使用中的注意细节</h3>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">final和abstract不能共存使用</span><br></pre></td></tr></table></figure>
<h2 id="权限修饰符">权限修饰符</h2>
<h3 id="权限修饰符是什么">权限修饰符是什么</h3>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">权限修饰符是java语言中的关键字，用于修饰：类、变量、方法</span><br><span class="line">权限修饰符：private 、public 、protected、默认(什么都不写)</span><br></pre></td></tr></table></figure>
<h3 id="权限修饰符号解决什么问题">权限修饰符号解决什么问题</h3>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">限制程序中的访问权限（类的访问权限、变量的访问权限、方法的访问权限）</span><br></pre></td></tr></table></figure>
<h3 id="权限修饰符怎么使用">权限修饰符怎么使用</h3>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//类（权限：公开的 [没有限制]）</span></span><br><span class="line"><span class="keyword">public</span> class 类&#123;</span><br><span class="line">    <span class="comment">//成员变量（私有权限：本类中使用）</span></span><br><span class="line">    <span class="keyword">private</span> String name;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">//默认权限（权限：当前包下的任意类）</span></span><br><span class="line">    <span class="keyword">void</span> <span class="title function_">show</span><span class="params">()</span>&#123;</span><br><span class="line">        </span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">//protected（权限：子类）</span></span><br><span class="line">    <span class="keyword">protected</span> <span class="keyword">void</span> <span class="title function_">method</span><span class="params">()</span>&#123;</span><br><span class="line">        </span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">从小到大排序：</span><br><span class="line"><span class="number">1.</span> <span class="keyword">private</span> <span class="comment">//访问范围： 仅现本类中访问</span></span><br><span class="line"><span class="number">2.</span> 默认     <span class="comment">//访问范围： 只能在同一个包下的类</span></span><br><span class="line"><span class="number">3.</span> <span class="keyword">protected</span>  <span class="comment">//访问范围： 同一个包下的任意类 或 不同包下的子类 </span></span><br><span class="line"><span class="number">4.</span> <span class="keyword">public</span>     <span class="comment">//访问范围 ：没有限制    </span></span><br></pre></td></tr></table></figure>
<h3 id="权限修饰符在使用中的注意细节">权限修饰符在使用中的注意细节</h3>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">//方法重写时：保障子类中重写访问的访问权限必须 &gt;= 父类中方法的权限</span><br></pre></td></tr></table></figure>
<h2 id="工具类">工具类</h2>
<h3 id="在开发中经常会使用或开发工具类">在开发中经常会使用或开发：工具类</h3>
<ul>
<li>工具类的特点：
<ol type="1">
<li>不能被继承</li>
<li>不能让其他类创建对象</li>
<li>提供静态方法</li>
</ol></li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//final保障 ：工具类不能被继承</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">final</span> class 工具类&#123;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">//不能让其他类创建对象</span></span><br><span class="line">    <span class="keyword">private</span> 工具类()&#123;&#125;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">//给外部提供：静态方法</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> 返回值 静态方法(...)&#123;</span><br><span class="line">        </span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="问题在一个类中可以书写哪些内容">问题：在一个类中可以书写哪些内容？</h3>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> class 类&#123;</span><br><span class="line">    <span class="comment">//成员变量：静态、非静态</span></span><br><span class="line">    </span><br><span class="line">    <span class="comment">//成员方法：静态、非静态、抽象</span></span><br><span class="line">    </span><br><span class="line">    <span class="comment">//构造方法</span></span><br><span class="line">    </span><br><span class="line">    <span class="comment">//代码块</span></span><br><span class="line">    </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="代码块">代码块：</h3>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="代码块划分">代码块划分：</h3>
<ul>
<li>静态代码块 //开发中使用最多
<ul>
<li>书写位置：在类中方法外（和成员变量、成员方法属于同一级）
<ul>
<li>在构造代码块上添加：static</li>
</ul></li>
<li>特点：随着类的加载，执行1次静态代码块（类只会被加载1次）</li>
<li>作用：用于对静态成员数据进行初始化</li>
</ul></li>
<li>构造代码块
<ul>
<li>书写位置：在类中方法外（和成员变量、成员方法属于同一级）</li>
<li>特点：在每个构造方法执行前，都会先执行构造代码块</li>
<li>作用：当类中多个构造方法中有共性内容时，可能抽取到构造代码块</li>
</ul></li>
<li>局部代码块
<ul>
<li>书写位置：写在方法体中</li>
<li>特点：在方法执行时，才会调用</li>
<li>作用：用于作用域</li>
</ul></li>
</ul>
<h2 id="接口">接口</h2>
<h3 id="接口的作用制定规则">接口的作用：制定规则</h3>
<h3 id="制定规则的两种方案">制定规则的两种方案：</h3>
<ol type="1">
<li>定义类，类中书写抽象方法（不建议使用。 类只能单一继承）</li>
<li>定义接口， 接口中书写抽象方法（接口好处：可以多实现）</li>
</ol>
<h3 id="接口的定义">接口的定义：</h3>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> interface  接口名&#123;</span><br><span class="line">     <span class="comment">//抽象方法</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="接口的特点">接口的特点：</h3>
<ol type="1">
<li>接口不能实例化（不能创建对象）</li>
<li>接口中没有构造方法（接口只能通过子类来实现对象创建）</li>
<li>接口可以多实现（ 一个类可以实现多个接口[解决类只能单一继承的问题]
）</li>
</ol>
<p>按照接口中定义的规则开发子类： 编写接口实现类</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> class 接口实现类 implements 接口&#123;</span><br><span class="line">    <span class="comment">//重写接口中所有的抽象方法</span></span><br><span class="line">&#125; </span><br></pre></td></tr></table></figure>
<p>接口的多实现：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> class 接口实现类 implements 接口<span class="number">1</span> , 接口<span class="number">2</span> , 接口<span class="number">3</span> &#123;</span><br><span class="line">    <span class="comment">//重写所实现接口中所有的抽象方法</span></span><br><span class="line">&#125; </span><br></pre></td></tr></table></figure>
<p>在接口可以书写的内容：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> interface 接口名&#123;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">//抽象方法</span></span><br><span class="line">    </span><br><span class="line">    <span class="comment">//静态常量</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">int</span> <span class="variable">NUMBER</span> <span class="operator">=</span> <span class="number">10</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ul>
<li><p>思考：静态常量在程序中做什么呢？</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">问题：生活中有没有一些数据是固定的，且值比较单一？</span><br><span class="line">示例：性别（固定、且仅有2个值）</span><br><span class="line"></span><br><span class="line">public interface Gender&#123;</span><br><span class="line">   public static final String BOY = &quot;男&quot;;</span><br><span class="line">   public static final String GIRL = &quot;女&quot;;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">//程序中需要给性别赋值</span><br><span class="line">String sex  = Gender.BOY;</span><br><span class="line">String sex = Gender.GIRL;</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure></li>
</ul>
<p>接口中的方法的升级：</p>
<ul>
<li>随着JDK版本的升级
<ul>
<li>在jdk1.8版本中新增：默认方法、静态方法 //有方法体代码</li>
<li>在jdk1.9版本中新增：私有方法 //有方法体代码</li>
</ul></li>
</ul>
<p>类和接口的概念：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">类和类之间的关系： 继承 （只能单一继承）</span><br><span class="line"><span class="keyword">public</span> 子类 extends 父类&#123;</span><br><span class="line">    </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">类和接口之间的关系：实现</span><br><span class="line"><span class="keyword">public</span> 子类 implements 接口&#123;</span><br><span class="line">    </span><br><span class="line">&#125; </span><br><span class="line">    </span><br><span class="line">   </span><br><span class="line">接口和接口之间的关系：继承 （允许多继承）</span><br><span class="line"><span class="keyword">public</span> 接口<span class="number">1</span> extends 接口<span class="number">2</span> &#123;</span><br><span class="line">    <span class="comment">//问题：为什么接口可以多继承？</span></span><br><span class="line">    <span class="comment">//答案：接口中仅仅只是定义功能（没有功能的实现，子类要自己实现功能）</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h3 id="接口和抽象类的相同之处">接口和抽象类的相同之处：</h3>
<ol type="1">
<li>接口和抽象类， 都不能实例化（不能创建对象）</li>
<li>接口和抽象类，都具有抽象方法</li>
<li>接口和抽象类，都是做为父类型存在的</li>
</ol>
<h3 id="抽象类和接口的区别">抽象类和接口的区别：</h3>
<ol type="1">
<li>抽象类：除了抽象方法外，还具有成员变量、构造方法、非抽象方法</li>
<li>接口：除了抽象方法外，只有常量
（JDK8：默认方法、静态方法）（JDK9：私有方法）</li>
</ol>
<h2 id="总结">总结：</h2>
<ol type="1">
<li><h3 id="static关键字">static关键字</h3>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//static是什么？</span></span><br><span class="line"><span class="keyword">static</span>是java语言中的修饰符关键字。用来修饰：变量、方法</span><br><span class="line">    </span><br><span class="line"><span class="comment">//static解决程序中的什么问题？</span></span><br><span class="line"><span class="keyword">static</span>可以让数据进行共享（多个对象可以使用同一个数据）</span><br><span class="line"> </span><br><span class="line"><span class="comment">//static的使用</span></span><br><span class="line"><span class="keyword">public</span> class 类&#123;</span><br><span class="line">    <span class="comment">//静态成员变量</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="type">int</span> count;</span><br><span class="line">    <span class="comment">//静态成员方法</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">method</span><span class="params">()</span>&#123;</span><br><span class="line">        </span><br><span class="line">    &#125;</span><br><span class="line">&#125; </span><br><span class="line">通过类名访问：静态成员</span><br><span class="line">类名.count = <span class="number">100</span>;</span><br><span class="line">类名.method();</span><br><span class="line"></span><br><span class="line"><span class="comment">//static在使用中的细节</span></span><br><span class="line"><span class="number">1.</span> <span class="keyword">static</span>修饰的内容是随着类的加载而存在的（早于对象的创建）</span><br><span class="line"><span class="number">2.</span> <span class="keyword">static</span>修饰的内容是存储在方法区的静态区别下（仅此一份）</span><br><span class="line"><span class="number">3.</span> <span class="keyword">static</span>修饰的静态方法中，只能访问静态成员</span><br><span class="line"><span class="number">4.</span> <span class="keyword">static</span>修饰的静态方法中，不能使用<span class="built_in">this</span>关键字</span><br><span class="line"><span class="number">5.</span> 非静态方法中可以访问：静态方法、静态变量</span><br></pre></td></tr></table></figure></li>
<li><h3 id="final关键字">final关键字</h3>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//final是什么？</span></span><br><span class="line"><span class="keyword">final</span>是java语言中的修饰符关键字。用来修饰：类、方法、变量</span><br><span class="line">    </span><br><span class="line"><span class="comment">//final可以解决程序中什么问题？</span></span><br><span class="line"><span class="keyword">final</span>修饰的类：不能被继承</span><br><span class="line"><span class="keyword">final</span>修饰的方法： 不能被重写</span><br><span class="line"><span class="keyword">final</span>修饰的变量： 初始化值后不能改变其值（常量）</span><br><span class="line">    </span><br><span class="line"><span class="comment">//final的使用</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">final</span> class 类名&#123;</span><br><span class="line">    <span class="comment">//变量</span></span><br><span class="line">    <span class="keyword">final</span> String name=<span class="string">&quot;初始化值&quot;</span>;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">//方法</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">void</span> <span class="title function_">method</span><span class="params">()</span>&#123;</span><br><span class="line">        </span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></li>
<li><h3 id="权限修饰符号">权限修饰符号</h3>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//权限修饰符解决什么问题？</span></span><br><span class="line">限制程序中访问权限</span><br><span class="line"></span><br><span class="line"><span class="comment">//权限修饰符</span></span><br><span class="line"><span class="keyword">private</span> 、默认（什么都不写）、<span class="keyword">protected</span> 、 <span class="keyword">public</span> </span><br><span class="line">    </span><br><span class="line"><span class="keyword">private</span>  ： 仅限本类中使用  </span><br><span class="line">默认（什么都不写） ： 同一个包下的任意类</span><br><span class="line"><span class="keyword">protected</span>  ： 同一个包下的任意类 、 不同包下的子类</span><br><span class="line"><span class="keyword">public</span>    ： 没有限制 </span><br></pre></td></tr></table></figure></li>
<li><h3 id="接口-1">接口</h3>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//接口的作用：</span></span><br><span class="line">制定规则 </span><br><span class="line">    </span><br><span class="line"></span><br><span class="line"><span class="comment">//接口的定义（语法）</span></span><br><span class="line"><span class="keyword">public</span> interface 接口名&#123;</span><br><span class="line">    <span class="comment">//抽象方法</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">abstract</span> <span class="type">boolean</span> <span class="title function_">login</span><span class="params">(String name, String password)</span>;</span><br><span class="line">&#125;    </span><br><span class="line">    </span><br><span class="line"><span class="comment">//接口的实现（语法） </span></span><br><span class="line"><span class="keyword">public</span> class 接口实现类 implements 接口名&#123;</span><br><span class="line">    <span class="comment">//重写：抽象方法</span></span><br><span class="line">    <span class="keyword">public</span> <span class="type">boolean</span> <span class="title function_">login</span><span class="params">(String name , String password)</span>&#123;</span><br><span class="line">        ......</span><br><span class="line">            </span><br><span class="line">        <span class="keyword">return</span> <span class="type">boolean</span>类型的值;    </span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//接口的特点：</span></span><br><span class="line"><span class="number">1</span>、接口不能实例化（不能创建对象）</span><br><span class="line"><span class="number">2</span>、接口中没有构造方法</span><br><span class="line"><span class="number">3</span>、接口可以多实现（解决类只能单一继承的问题）</span><br><span class="line">    实现类 可以在继承一个父类的情况下，还可以实现多个接口</span><br><span class="line">    <span class="keyword">public</span> class 子类 extends 父类 implements 接口A , 接口B&#123;</span><br><span class="line">        <span class="comment">//重写所有抽象方法</span></span><br><span class="line">    &#125;</span><br><span class="line">    </span><br></pre></td></tr></table></figure></li>
<li><h3 id="代码块-1">代码块</h3>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">代码块：局部代码块、构造代码块、静态代码块</span><br><span class="line">    </span><br><span class="line">构造代码块作用：当类中构造方法里面有共性内容时，可以抽出到构造代码块中</span><br><span class="line">             每次构造方法执行前，都会先执行构造代码块</span><br><span class="line">    </span><br><span class="line">静态代码块：</span><br><span class="line"><span class="keyword">static</span>&#123;</span><br><span class="line">    <span class="comment">//特点：静态代码块是随着类的加载执行（执行1次）</span></span><br><span class="line">    <span class="comment">//作用：初始化数据（数据必须在创建对象之前就初始化完成）</span></span><br><span class="line">&#125;    </span><br></pre></td></tr></table></figure></li>
</ol>
<h2 id="选择语句">选择语句：</h2>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">switch</span>( 常量表达式 )&#123; <span class="comment">//只能使用：byte、short、int、char、String、枚举</span></span><br><span class="line">    <span class="keyword">case</span> 常量值<span class="number">1</span>:</span><br><span class="line">        语句<span class="number">1</span>;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    ...    </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="枚举">枚举</h2>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//什么是枚举</span></span><br><span class="line">在java语言中，枚举是一种数据类型。枚举用来表示：固定且仅有几种取值范围的数据</span><br><span class="line">例：性别</span><br><span class="line">    </span><br><span class="line"><span class="keyword">public</span> <span class="keyword">interface</span> <span class="title class_">Gender</span>&#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> String BOY=<span class="string">&quot;男&quot;</span>;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> String GIRL=<span class="string">&quot;女&quot;</span>;</span><br><span class="line">&#125;    </span><br><span class="line">    </span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Student</span>&#123;</span><br><span class="line">    <span class="keyword">private</span> String name;</span><br><span class="line">    <span class="keyword">private</span> String sex;</span><br><span class="line">    <span class="keyword">public</span> <span class="title function_">Student</span><span class="params">(String name , String sex)</span>&#123;</span><br><span class="line">        <span class="built_in">this</span>.name = name;</span><br><span class="line">        <span class="built_in">this</span>.sex = sex;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="type">Student</span> <span class="variable">stu</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Student</span>(<span class="string">&quot;熊大&quot;</span>, Gender.BOY);</span><br><span class="line"></span><br><span class="line"><span class="type">Student</span> <span class="variable">stu</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Student</span>(<span class="string">&quot;熊二&quot;</span>, <span class="string">&quot;男女&quot;</span>);<span class="comment">//不会报错</span></span><br><span class="line">解决方案： 枚举类型</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">//枚举解决程序中的什么问题？</span></span><br><span class="line">当程序中有数据是固定且只有几种取值范围时，使用枚举类型强制设置值的范围（赋值数据有保障）    </span><br><span class="line">    </span><br><span class="line"></span><br><span class="line"><span class="comment">//枚举怎么使用？</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">enum</span> <span class="title class_">Gender</span>&#123;</span><br><span class="line">    BOY , GIRL;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Student</span>&#123;</span><br><span class="line">    <span class="keyword">private</span> String name;</span><br><span class="line">    <span class="comment">//使用枚举类型</span></span><br><span class="line">    <span class="keyword">private</span> Gender gender;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">public</span> <span class="title function_">Student</span><span class="params">(String name , Gender gender)</span>&#123;</span><br><span class="line">        <span class="built_in">this</span>.name = name;</span><br><span class="line">        <span class="built_in">this</span>.gender = gender;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="type">Student</span> <span class="variable">stu</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Student</span>(<span class="string">&quot;熊二&quot;</span>, <span class="string">&quot;男女&quot;</span>);<span class="comment">//报错。原因：性别类型必须是Gender枚举</span></span><br><span class="line"></span><br><span class="line"><span class="type">Student</span> <span class="variable">stu</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Student</span>(<span class="string">&quot;熊二&quot;</span>, Gender.BOY);<span class="comment">//正确（保障数据的合法有效性）</span></span><br><span class="line"></span><br><span class="line">    </span><br><span class="line">    </span><br><span class="line"></span><br><span class="line"><span class="comment">//枚举在使用中的注意细节</span></span><br><span class="line"><span class="number">1.</span> 枚举本质是一个类</span><br><span class="line"><span class="number">2.</span> 在枚举中除了可以书写：固定选项值外，还可以书写：成员变量、私有构造方法、成员方法</span><br></pre></td></tr></table></figure>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="reward-container">
  <div>请我一杯咖啡吧！</div>
  <button>
    赞赏
  </button>
  <div class="post-reward">
      <div>
        <img src="/images/wChat.png" alt="Ethan Liu 微信">
        <span>微信</span>
      </div>

  </div>
</div>

          

<div class="post-copyright">
<ul>
  <li class="post-copyright-author">
      <strong>本文作者： </strong>Ethan Liu
  </li>
  <li class="post-copyright-link">
      <strong>本文链接：</strong>
      <a href="http://ethanliu6.github.io/2024/04/01/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day02/day02_JavaSE%E8%BF%9B%E9%98%B6-%E4%BB%A3%E7%A0%81%E5%9D%97,%E6%8E%A5%E5%8F%A3,%E6%9E%9A%E4%B8%BE/" title="JavaSE进阶——Day02 代码块、接口、枚举">http://ethanliu6.github.io/2024/04/01/JavaNotes/JavaSE进阶/day02/day02_JavaSE进阶-代码块,接口,枚举/</a>
  </li>
  <li class="post-copyright-license">
      <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <span class="exturl" data-url="aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzQuMC8="><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</span> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


          <div class="post-tags">
              <a href="/tags/Java/" rel="tag"><i class="fa fa-tag"></i> Java</a>
              <a href="/tags/Java%E8%BF%9B%E9%98%B6/" rel="tag"><i class="fa fa-tag"></i> Java进阶</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2024/03/25/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day01/day01_JavaSE%E8%BF%9B%E9%98%B6-%E7%BB%A7%E6%89%BF,%E6%8A%BD%E8%B1%A1%E7%B1%BB/" rel="prev" title="JavaSE进阶——Day01 继承、抽象类">
                  <i class="fa fa-angle-left"></i> JavaSE进阶——Day01 继承、抽象类
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2024/04/04/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day03/day03_JavaSE%E8%BF%9B%E9%98%B6-%E5%A4%9A%E6%80%81,%E5%86%85%E9%83%A8%E7%B1%BB/" rel="next" title="JavaSE进阶——Day03 多态、内部类、时间日期格式类">
                  JavaSE进阶——Day03 多态、内部类、时间日期格式类 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






    <div class="comments" id="SOHUCS" sid="9a71e76ad768294a3365a5c88a5c26ab"></div>
</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2023-2024 – 
    <span itemprop="copyrightYear">2024</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">Is Ethan's</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
    <span title="站点总字数">113k</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">6:51</span>
  </span>
</div>
<div class="busuanzi-count">
    <span class="post-meta-item" id="busuanzi_container_site_uv">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-item" id="busuanzi_container_site_pv">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>

    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>
  <a role="button" class="book-mark-link book-mark-link-fixed"></a>

  <span class="exturl github-corner" data-url="aHR0cHM6Ly9naXRodWIuY29tL0V0aGFuTGl1Ni8=" title="在 GitHub 上关注我" aria-label="在 GitHub 上关注我"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></span>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.33/fancybox/fancybox.umd.js" integrity="sha256-+2+qOqR8CKoHh/AsVR9k2qaDBKWjYNC2nozhYmv5j9k=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/medium-zoom/1.1.0/medium-zoom.min.js" integrity="sha256-ZgMyDAIYDYGxbcpJcfUnYwNevG/xi9OHKaR/8GK+jWc=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/bookmark.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>

  <script class="next-config" data-name="pdf" type="application/json">{"object_url":{"url":"https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.2.12/pdfobject.min.js","integrity":"sha256-g2xji1rlE3KsGVClvuxTbcR0Kn2+wtQADSff2Tbb4zA="},"url":"/lib/pdf/web/viewer.html"}</script>
  <script src="/js/third-party/tags/pdf.js"></script>



  <script src="/js/third-party/fancybox.js"></script>



  
  <script data-pjax async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"all","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


  <script src="https://cdnjs.cloudflare.com/ajax/libs/quicklink/2.3.0/quicklink.umd.js" integrity="sha256-yvJQOINiH9fWemHn0vCA5lsHWJaHs6/ZmO+1Ft04SvM=" crossorigin="anonymous"></script>
  <script class="next-config" data-name="quicklink" type="application/json">{"enable":true,"home":true,"archive":true,"delay":true,"timeout":3000,"priority":true,"url":"http://ethanliu6.github.io/2024/04/01/JavaNotes/JavaSE%E8%BF%9B%E9%98%B6/day02/day02_JavaSE%E8%BF%9B%E9%98%B6-%E4%BB%A3%E7%A0%81%E5%9D%97,%E6%8E%A5%E5%8F%A3,%E6%9E%9A%E4%B8%BE/"}</script>
  <script src="/js/third-party/quicklink.js"></script>
<script class="next-config" data-name="changyan" type="application/json">{"enable":true,"appid":"cyxf6tytI","appkey":"90987f30c4b5248baad5a04c7a6abfe1","count":true}</script>
<script src="/js/third-party/comments/changyan.js"></script>

</body>
</html>
